package com.wn.pettyloan.service.impl;

import com.wn.pettyloan.dto.DocumentDto;
import com.wn.pettyloan.entity.Document;
import com.wn.pettyloan.mapper.DocumentMapper;
import com.wn.pettyloan.service.DocumentService;
import com.wn.pettyloan.util.BeanCopyUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.xml.crypto.Data;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @program: pettyloan
 * @ClassName DocumentServiceImpl
 * @author: lwb
 * @create: 2022-12-09 22:32
 **/
@Service
public class DocumentServiceImpl implements DocumentService {
    @Resource
    private DocumentMapper documentMapper;
    @Override
    public int batchInsert(DocumentDto[] docDtos) {

        Date date = new Date();
        int j = 0;
        for (int i = 0; i < docDtos.length; i++) {
            Document document = BeanCopyUtils.copyBean(docDtos[i], Document.class);
            document.setDocumentTime(date);
            documentMapper.insert(document);
            j++;
        }
        return j;
    }

}
